package com.heiye.blog.ai.domain.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.heiye.blog.ai.domain.dos.RoleDO;

/**
 * @author: heiye
 * @date: 2025/10/31 下午4:31
 * @version: v1.0.0
 * @description: TODO
 */
public interface RobotMapper extends BaseMapper<RoleDO> {

    /**
     * 分页查询
     *
     * @param current
     * @param size
     * @return
     */
    default Page<RoleDO> selectPageList(Long current, Long size) {
        // 分页对象(查询第几页、每页多少数据)
        Page<RoleDO> page = new Page<>(current, size);

        // 构建查询条件
        LambdaQueryWrapper<RoleDO> wrapper = Wrappers.<RoleDO>lambdaQuery()
                .ne(RoleDO::getId, 1L)
                // 按创建时间倒序
                .orderByDesc(RoleDO::getCreateTime);

        return selectPage(page, wrapper);
    }
}
